//
//  BaseColllectionViewController.m
//  Share_Home_F
//
//  Created by dllo on 15/4/21.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "BaseColllectionViewController.h"
#import "BaseCollectionViewCell.h"
#import "BaseCollectionModel.h"
@interface BaseColllectionViewController ()

@end

@implementation BaseColllectionViewController
-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
       
     }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
#pragma mark 创建基类的UICollectionView
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.itemSize = CGSizeMake(124, 124);
    flowLayout.minimumInteritemSpacing = 1;
    flowLayout.minimumLineSpacing = 1;
    flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
   
    self.collectionView = [[UICollectionView alloc] initWithFrame:[[UIScreen mainScreen] bounds] collectionViewLayout:flowLayout];
    
    self.collectionView.dataSource = self;
    self.collectionView.delegate = self;
    [self.view addSubview:self.collectionView];
    
//    self.collectionView.backgroundColor = [UIColor colorWithRed:arc4random() % 256 / 255.0 green:arc4random() % 256 / 255.0  blue:arc4random() % 256 / 255.0  alpha:1.0];
    self.collectionView.backgroundColor = [UIColor whiteColor];

    [_collectionView release];
    [self.collectionView registerClass:[BaseCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([BaseCollectionModel class])];
/*
#pragma mark 创建收藏分享按钮
    UIButton *collectButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [collectButton setTitle:@"收藏" forState: UIControlStateNormal];
    collectButton.frame = CGRectMake(0, 520, 100, 30);
    collectButton.backgroundColor = [UIColor cyanColor];
    [self.view addSubview:collectButton];
    
    UIButton *shareButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [shareButton setTitle:@"分享" forState: UIControlStateNormal];
    shareButton.frame = CGRectMake(275, 520, 100, 30);
    shareButton.backgroundColor = [UIColor cyanColor];
    [self.view addSubview:shareButton];

    
   */
    
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    BaseCollectionModel *collectionModel = [[BaseCollectionModel alloc] init];
    return [collectionModel.modelArr count];
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    BaseCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([BaseCollectionModel class]) forIndexPath:indexPath];
   
    
    
    return cell;
}
- (void)dealloc
{
    [_collectionView release];
    [super dealloc];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
